<?php
session_start();
include "../php/config.php";
include "../php/paging.php";
if(empty($_SESSION["login.username"]))
	die("<meta http-equiv='refresh' content='0;URL=logout.php'>");
$menu = $_GET["m"];
if(empty($menu))
	$menu = "barang";
$submenu = $_GET["md"];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
	<title>Media Marketindo - Customer Page</title>
	<link href="../css/style.css" rel="stylesheet" type="text/css" />
	<link rel="stylesheet" type="text/css" media="screen" href="css/jqgrids/jquery-ui-1.8.11.custom.css" />
	<link rel="stylesheet" type="text/css" media="screen" href="css/jqgrids/jquery.ui.css" />
	<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
	<style type="text/css">
	.hiding
	{
		display: none;
	}
	</style>
	<script src="../js/clockp.js" type="text/javascript"></script>
	<script src="../js/clockh.js" type="text/javascript"></script> 
	<script src="../js/jquery.min.js" type="text/javascript"></script>
	<script src="../js/grid.locale-en.js" type="text/javascript"></script>
	<script src="../js/jquery.jqGrid.min.js" type="text/javascript"></script>
	<script src="../js/jconfirmaction.jquery.js" type="text/javascript"></script>
	<script language="javascript" type="text/javascript">
	var imagesPath = "../css/images/";
	</script>
	<script language="javascript" src="../js/niceforms.js" type="text/javascript"></script>
	<link href="../css/niceforms-default.css" media="all" rel="stylesheet" type="text/css" />
	<script language="javascript" src="../js/jquery.validate.js" type="text/javascript"></script>
	<link href="../css/jquery_validation.css" rel="stylesheet" type="text/css" />
	<script language="javascript" type="text/javascript">
	var visible = <?php if(!empty($_SESSION["cart.id"])) echo "1"; else echo "0";?>;
	var round_decimal = <?php if(!empty($_SESSION["setting.decimal"])) echo $_SESSION["setting.decimal"]; else echo "0";?>,
	round_money = <?php if(!empty($_SESSION["setting.money"])) echo $_SESSION["setting.money"]; else echo "0";?>;
	$(function()
	{
		$("#cart_checkbox").change(function()
		{
			if(visible == 0)
			{
				$("#cart_table").attr("class","");
				visible = 1;
			}
			else if(visible == 1)
			{
				$("#cart_table").attr("class","hiding");
				visible = 0;
			}
		});
		$("#form_search").submit(function()
		{
			var keyword = $("#keyword").val();
			if(!keyword)
				alert("Keyword masih kosong");	
			else
				return true;
			return false;
		});
		$(".ask").jConfirmAction();
	});
	function link_confirmation(message,href)
	{
		if(confirm(message))
			document.location.href = href;
	}
	</script>
	<script language="javascript" src="js/inc_<?php echo $menu; ?>.js" type="text/javascript"></script>
</head>
<body>
	<div id="main_container">
		<div class="header">
			<div class="logo"><br></div>
			<div class="right_header">
				Hai, <a href="?m=profile"><?php echo $_SESSION["login.name"]; ?></a> 
				| 
				<a class="logout" href="logout.php">Logout</a>
			</div>
			<div id="clock_a"></div>
		</div>
		<div class="main_content">
			<div class="menu">
				<ul>
					<li><a <?php if($menu == "barang") echo "class=\"current\""; ?> href="?m=barang">Home</a></li>
					<li><a <?php if($menu == "order") echo "class=\"current\""; ?> href="?m=order&md=order">History<!--[if IE 7]><!--></a><!--<![endif]-->
					<!--[if lte IE 6]><table><tr><td><![endif]-->
						<ul>
							<li><a <?php if($menu == "order" && $submenu == "draft") echo "class=\"current\""; ?> href="?m=order&md=draft" title="">Draft</a></li>
							<li><a <?php if($menu == "order" && $submenu == "order") echo "class=\"current\""; ?> href="?m=order&md=order" title="">Order</a></li>
						</ul>
						<!--[if lte IE 6]></td></tr></table></a><![endif]-->
					</li>
					<li><a <?php if($menu == "profile") echo "class=\"current\""; ?> href="?m=profile">Profile</a></li>
				</ul>
			</div>
			<div class="center_content">
				<div class="left_content">
					<div class="sidebar_search">
						<form action="?m=barang" id="form_search" method="post">
							<input class="search_input" id="keyword" name="keyword" type="text" value="search keyword" onclick="this.value=''" />
							<input class="search_submit" src="../images/search.png" type="image" />
						</form>
					</div>
					<div class="sidebar_box">
						<div class="sidebar_box_top"></div>
						<div class="sidebar_box_content">
							<?php
							if(!empty($submenu))
								$string_submenu = "_$submenu";
							@include "filters/$menu$string_submenu.php";
							?>
						</div>
						<div class="sidebar_box_bottom"></div>
					</div>
				</div>
				<div class="right_content">
					<?php 
					if(empty($_SESSION["login.password"]))
					{
						$check_customer = mysql_num_rows(mysql_query("SELECT * FROM mcustomer WHERE intNomor = ".$_SESSION["login.id"]." AND vcMD5Password IS NULL AND intStatus = 1"));
						if($check_customer > 0)
							echo "<div class=\"warning_box\">Anda harus memperbaharui password terlebih dahulu sebelum dapat melakukan pemesanan barang. Klik di <a href=\"?m=profile\">sini</a> untuk mengupdate password.</div>";
					}
					if(!empty($_SESSION["$menu.warning_msg"]))
					{
						echo "<div class=\"";
						if(!empty($_SESSION["$menu.warning_box"]))
							echo $_SESSION["$menu.warning_box"];
						else
							echo "warning";
						echo "_box\">".$_SESSION["$menu.warning_msg"]."</div>";
						unset($_SESSION["$menu.warning_msg"]);
						unset($_SESSION["$menu.warning_box"]);
					}
					@include "contents/$menu.php";
					if($menu != "cart")
					{
						echo "<br /><br /><br /><hr /><br />";
						include "contents/cart.php"; 
					}
					?>
				</div>
			</div>
			<div class="clear"></div>
		</div>
		<div class="footer"></div>
	</div>
</body>
</html>